import { Exclude, Expose, Transform } from 'class-transformer';

export class PublicUserDto {
  @Expose()
  id: string;

  @Expose()
  username: string;

  @Exclude() // 排除
  password: string;

  @Transform(({ value }) => {
    console.log('value', value);
    if (!value) return;
    return value.map((item) => ({
      id: item.Role.id,
      permissions: item.Role.RolePermissions,
    }));
  })
  @Expose({ name: 'UserRole' })
  roles: any;
}
